<?php

namespace console\db\channels;

/**
 * 数据表直接复制迁移
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
abstract class TransferTableIncrementMigration extends TransferTableMigration {

    /**
     * @inheritdoc
     */
    public $sourceDb = 'transDb';

    /**
     * @var bool 是否先清理本地数据表
     */
    public $beforeTruncateTargetTable = false;

    /**
     * @inheritdoc
     */
    public function afterTransfer($tableName) {
        parent::afterTransfer($tableName);
        $tableBatchRecord = $this->getBatchIncrementTable($tableName);
        if (!empty($tableBatchRecord)) {
            $this->update('{{%' . $this->mirgrationBatchTable . '_table}}', [
                'status' => 10
            ], ['id' => $tableBatchRecord['id']]);
        }
    }

}
